<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
<div id="app">
    <h1>index.html</h1>
    <input type="button" value="测试SpringMVC处理ajax请求" @click="testAjax">
    <input type="button" value="测试RequestBody" @click="testRequestBody">
    <a th:href="@{/test/download}">测试download</a>
    <br>
    <br>
    <br>
    <form th:action="@{/test/upload}" method="post" enctype="multipart/form-data">
        头像：<input type="file" name="photo">
        <input type="submit" value="上传">
    </form>
</div>
<script type="text/javascript" th:src="@{/js/vue.js}"></script>
<script type="text/javascript" th:src="@{/js/axios.min.js}"></script>
<script type="text/javascript">
    var vue = new Vue({
        el: "#app",
        methods: {
            testAjax: function () {
                axios.post("/SpringMVC/test/ajax?id=1001",
                    {username: "admin", password: "123456"}).then(response => {
                        console.log(response.data);
                    }
                )
            },
            testRequestBody() {
                axios.post("/SpringMVC/requestbody",
                    {username: "admin", password: "123456"}).then(response => {
                    console.log(response.data);
                })
            },
            testDownload() {
                axios.get("/SpringMVC/test/download")
            }
        }
    });
</script>
</body>
</html>
